package com.kw.drug.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kw.drug.entity.Druginfo;
import com.kw.drug.entity.Problem;
import com.kw.drug.entity.Supplier;
import com.kw.drug.mapper.SaleinfoMapper;
import com.kw.drug.mapper.SupplierMapper;
import com.kw.drug.service.SupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SupplierServiceImpl implements SupplierService {
    @Autowired
    SupplierMapper supplierMapper;


    @Override
    public Page<Supplier> selectForsupplierList(int pageNum, int pageSize, String param) {
        QueryWrapper<Supplier> wrapper = new QueryWrapper<>();

        if (StringUtils.isNotEmpty(param)) {
            wrapper.like("name", param);
        }
        Page<Supplier> page = new Page<>(pageNum, pageSize);
        Page<Supplier> supplierPage = supplierMapper.selectPage(page, wrapper);
        return supplierPage;
    }

    @Override
    public Supplier selectSupplierById(Integer id) {
        Supplier supplier = supplierMapper.selectById(id);
        return supplier;
    }

    @Override
    public Integer updateSupplier(Supplier supplier) {
        int i = supplierMapper.updateById(supplier);
        return i;
    }

    /*
     * 添加供应商*/
    @Override
    public Integer addSupplier(Supplier supplier) {
        int insert = supplierMapper.insert(supplier);
        return insert;
    }
}

